/**
 * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.tmq.diancan.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.tmq.diancan.entity.DiancanOrderDetail;
import com.tmq.diancan.entity.OrderDetail;
import com.tmq.diancan.enums.OrderStatusEnum;
import com.tmq.diancan.utils.EnumUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 订单商品数据传输对象实体类
 *
 * @author tangmqb
 * @since 2020-03-21
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class DiancanOrderDetailDTO extends DiancanOrderDetail {
	private static final long serialVersionUID = 1L;
	/**
	 * 订单状态, 默认为0新下单.
	 * NEW(0, "新订单，未支付"),
	 * NEW_PAYED(0, "新订单，已支付"),
	 * FINISHED(1, "完结"),
	 * CANCEL(2, "已取消"),
	 */
	private Integer orderStatus;

	private String orderStatusStr;

	List<DiancanOrderDetail> orderDetailList;

	@JsonIgnore
	public OrderStatusEnum getOrderStatusEnum() {
		return EnumUtil.getByCode(orderStatus, OrderStatusEnum.class);
	}

	@JsonIgnore
	public String getOrderStatusStr(Integer orderStatus2) {
		return EnumUtil.getByCode(orderStatus2, OrderStatusEnum.class).getMessage();
	}
}
